home *** CD-ROM | disk | FTP | other *** search
- Path: news.walrus.com!news
- From: fjordao@walrus.com (Felipe Jordao)
- Newsgroups: comp.lang.c++
- Subject: Re: [Q] Converting dates in MMYY to YYMMDD format
- Date: Fri, 26 Jan 1996 03:14:54 GMT
- Organization: HAC
- Message-ID: <4e9h1h$kr7@walrus2.walrus.com>
- References: <4e6ms8$ad5@walrus2.walrus.com> <3107B2BE.794B@vnet.ibm.com>
- NNTP-Posting-Host: p19.ts1.walrus.com
- X-Newsreader: Forte Free Agent 1.0.82
-
- Philip Staite <pstaite@vnet.ibm.com> wrote:
- : Your example output looks like YYMMDD not DDMMYY... Anyway, try this:
-
- Actually, my mistake, it's YYMMDD that I want. I came up with the
- same logic that you did but not quite as concise, thanks for the tip.
- One thing that's missing though is if we're in 96 feb has 29 days not
- 28. What I did was use a switch statement for the dates and then
- tested for a leap year there.
-
- Felipe
-
- : #include<iostream.h>
- : long mn[ 12 ] = { 31, 28, 31, 30, 31, 30,
- : 31, 31, 30, 31, 30, 31 };
- : int main() {
- : long n;
- : cin >> n; // get date
- : cout << ( mn[ n / 100 - 1 ] + ( n / 100 ) * 100 + ( n % 100 ) *
- : 10000 ) << endl;
- : return 0; }
-
-
-